//
//  MARightTipView.m
//  meiang_edu
//
//  Created by 栋 on 2018/12/31.
//  Copyright © 2018年 com.meiang.meiang_edu. All rights reserved.
//

#import "MARightTipView.h"

@interface MARightTipView()

/**
 提示信息
 */
@property (weak, nonatomic) IBOutlet UILabel *lblTips;

@end

@implementation MARightTipView

+(void)showWithTips:(NSString *)tips{
    MARightTipView * view = [[[NSBundle mainBundle] loadNibNamed:@"MARightTipView" owner:nil options:nil] lastObject];
    view.lblTips.text = tips;
    [[[[UIApplication sharedApplication] delegate] window] addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    [view.superview layoutIfNeeded];
    [view animateShow:YES];
}

- (void)animateShow:(BOOL)show{
    self.alpha = !show?1.0:0;
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = show?1.0:0;
    } completion:^(BOOL finished) {
        if (!show) {
            [self removeFromSuperview];
        }
    }];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self animateShow:NO];
}

@end
